from tkinter import Canvas, Frame, BOTH

class GraphicsInterface(Frame) :
    def __init__(self, parent) :
        Frame.__init__(self, parent)

        self.parent = parent
        self.initUI()

    def initUI(self) :
        self.parent.title("Roadmap")
        self.pack(fill=BOTH, expand=1)

    def drawMap(self, nodes) :
        canvas = Canvas(self)
        drawnLinks = []
        for node in nodes :
            canvas.create_oval(node.x - 10, node.y -10, node.x + 10, node.y + 10, outline="black", fill="grey", width=2)
        for node in nodes :
            canvas.create_text(node.x - 9, node.y - 19, text=node.name, fill="black", font=("Consolas", 12))             
            canvas.create_text(node.x - 10, node.y - 20, text=node.name, fill="purple", font=("Consolas", 12))
            for child in node.children :
                if (node, child) not in drawnLinks and (child, node) not in drawnLinks :
                    canvas.create_line(node.x, node.y, child.x, child.y, fill="blue", width=2)
                    drawnLinks.append((node, child))
        canvas.pack(fill=BOTH, expand=1)